﻿@{
    ViewBag.Title = "Index";
    var uri = Url.Action(MVC.Dungeon.Details());
    var baseUri = uri.Contains("?") ? uri.Substring(0, uri.IndexOf("?")) : uri;
}

<h2>Index</h2>
<div class="error">@ViewBag.Error</div>
<div>Seed:<input data-bind="value:seed" type="number" /></div>
<div>X:<input data-bind="value:x" type="number" min="10"/></div>
<div>Y:<input data-bind="value:y" type="number" min="10" /></div>
<div>Features desired:<input data-bind="value:features" type="number" min="1" /></div>

<a href="#" data-bind="attr:{href:uri}">View Dungeon</a>
@section scripts
{
    @Scripts.Render(Links.Scripts.knockout_2_1_0_js)
    <script>
        var uri = '@baseUri';
        var GeneratorModel = function() {
            var self = this;
            self.seed = ko.observable(0);
            self.x = ko.observable(20);
            self.y = ko.observable(15);
            self.features = ko.observable(10);
            self.uri = ko.computed(function() {
                return uri + "?seed=" + self.seed() + "&x=" + self.x() + "&y=" + self.y() + "&features=" + self.features();
            });
        };
        var komodel = new GeneratorModel();
        ko.applyBindings(komodel);
    </script>
}
